Skip to content

fix(tui): isolate lifecycle and theme tests - #41310

Merged
kitlangton merged 1 commit into
v2from
stabilize-tui-tests
Aug 9, 2026
Merged

fix(tui): isolate lifecycle and theme tests#41310
kitlangton merged 1 commit into
v2from
stabilize-tui-tests

Conversation

@kitlangton

Copy link
Copy Markdown
Contributor

What

Stabilizes the seven TUI tests that failed on both Linux and Windows when v2 branch CI was enabled: four app lifecycle tests and three invalid-theme fallback variants.

Before / After

Before: lifecycle tests installed a process-global Bun module mock for @opentui/core after creating a test renderer. Test files can import the same module concurrently, so CI could retain the unmocked createCliRenderer; the SIGHUP test then timed out with a real renderer owning stdin, and the next lifecycle tests cascaded with stdin is already used by another CliRenderer. This pattern originated in 106f8e94d67.

After: lifecycle tests use the app's existing terminalHandoff input to supply their renderer directly. No module cache or global mock ordering is involved, and scoped cleanup releases the exact renderer owned by each test.

Before: the invalid-theme tests used an already-resolved discovery promise. Theme discovery could emit its error before the child probe's onError subscription was installed, leaving failure undefined on faster CI runners. This race originated with the fallback tests in 8f3465c951a and remained after the hook split in 08b80da9310.

After: discovery is held behind a test-owned promise and released after the renderer and probe are mounted, so each fallback assertion observes the intended error.

How

  • packages/tui/test/app-lifecycle.test.tsx replaces four mock.module setups with terminalHandoff.
  • packages/tui/test/cli/tui/theme-mode.test.tsx explicitly sequences invalid-theme discovery after subscription setup.
  • This fixes the tests rather than reverting TUI behavior because the failures are test isolation/timing defects; local product behavior and assertions were already correct.

Scope

This PR does not change runtime TUI behavior. The independent core session-runner cassette and plugin flush failures are handled separately.

Testing

  • cd packages/tui && bun typecheck passes.
  • cd packages/tui && bun run test test/app-lifecycle.test.tsx test/cli/tui/theme-mode.test.tsx passes three consecutive runs: 9 tests each, 0 failures.
  • cd packages/tui && bun run test passes: 607 passed, 5 skipped, 0 failed across 97 files.
  • The repository pre-push typecheck passes all 33 configured package tasks.

@kitlangton
kitlangton merged commit ff0a0b0 into v2 Aug 9, 2026
8 of 10 checks passed
@kitlangton
kitlangton deleted the stabilize-tui-tests branch August 9, 2026 00:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant